import {
  defineStore
} from 'pinia'
import {
  ref,
  computed
} from "vue";

export const useMemberStore = defineStore(
  "member",
  () => {
    // 用户token
    const profile = ref();
    // 设置用户信息的方法
    const setProfile = (useInfo) => {
      profile.value = useInfo;
      // console.log("设置用户信息的方法", useInfo);
    };
    //用户头像
    const avatar = ref(
      "https://www.yunyoutongxin.com/image/file668261d440714737be1ffcca99e46d17.png"
    );
    const setAvatar = (ava) => {
      avatar.value = ava;
    };
    //用户名
    const username = ref('账号名');
    const setusername = (e) => {
      username.value = e;
      // console.log(e, 777);
    };
    // 累计
    const userLJ = ref("");
    const setuserLJ = (LJ) => {
      userLJ.value = LJ;
    };
    // 预估
    const userYG = ref("");
    const setuserYG = (YG) => {
      userYG.value = YG;
    };
    // 手机号
    const usermobile = ref("");
    const setusermobilee = (mb) => {
      usermobile.value = mb;
    };
    // 邀请码
    const userinvite = ref("");
    const setuserinvite = (yq) => {
      userinvite.value = yq;
    };
    // 用户id
    const userid = ref("");
    const setuserid = (id) => {
      userid.value = id;
    };
    // 用户余额 user_balance
    const userbalance = ref("");
    const setbalance = (ye) => {
      userbalance.value = ye;
    };
    //  用户订单详情 order
    const userorder = ref("");
    const setorder = (or) => {
      userorder.value = or;
    };
    return {
      profile,
      avatar,
      username,
      userLJ,
      userYG,
      usermobile,
      userinvite,
      userid,
      userbalance,
      userorder,
      setProfile,
      setAvatar,
      setusername,
      setuserLJ,
      setuserYG,
      setusermobilee,
      setuserinvite,
      setuserid,
      setbalance,
      setorder,
    };
  }, {
    persist: {
      storage: {
        getItem(key) {
          return uni.getStorageSync(key);
        },
        setItem(key, value) {
          return uni.setStorageSync(key, value);
        },
      },
    },
  }
);